import pandas as pd
import os
from openpyxl import load_workbook
from colorama import init
init(autoreset=True)
#得到唯一xlsx文件
def getXlsx():
    current_directory = os.getcwd()
    files = os.listdir(current_directory)
    return [file for file in files if file.endswith('.xlsx')][0]
def filterTitle():
    df = pd.read_excel(getXlsx(), engine='openpyxl')
    # 获取第一行的标题（列名）
    return [cell.replace(" ","").replace("\n","") for cell in df.columns.tolist()]
# 筛选每一行的数据集
def filterData():
    # 加载工作簿
    workbook = load_workbook(getXlsx())
    # 选择工作表
    sheet = workbook.active
    row_list = []
    max_row=sheet.max_row
    for i in range(3,max_row+1):
        list=[]
        for  row in sheet[i]:
            list.append(row.value)
        row_list.append(tuple(list))
    return row_list
print("\033[32m解析您的xlsx表格的字段为: \033[0m ")
print( ",".join("`"+col+"`" for col in filterTitle()))